package com.lpc.android.abc.main.mvp;

import com.lpc.android.abc.base.api.ApiCallback;
import com.lpc.android.abc.base.base.BasePresenter;
import com.lpc.android.abc.base.bean.HomeCampaign;

import java.util.List;

/**
 * Created by lipc0113 on 2017/6/16 0016.
 */

public class MainPresenter extends BasePresenter<MainContract.Model, MainContract.View>{

    public MainPresenter(MainContract.View view) {
        super(view);
        mModel = new MainModel();
    }

    public void getHomeInfo() {

        addSubscription(mModel.getHomeInfo(), newMySubscriber(new ApiCallback<List<HomeCampaign>>() {

            @Override
            public void onNext(List<HomeCampaign> lists) {

                if(mView != null){
                    mView.homeInfoSuccess(lists);
                }
            }

            @Override
            public void onError(Throwable throwable) {
                if(mView != null){
                    mView.homeInfoFail(throwable.getMessage());
                }
            }
        }));

    }
}
